<script setup>
import { onMounted, onUnmounted, ref } from "vue";
import router from "@/router/index";
import { _$, $ } from "./edit";

const formRef = ref();

onMounted(() => {
  $.init([formRef]);
  if (router.currentRoute.value.query.id) {
    _$.requestParam.id = router.currentRoute.value.query?.id;
    $.loadEdit();
  }
});

onUnmounted(() => {
  $.clean();
});
</script>

<template>
  <el-space direction="vertical" fill wrap class="w-fill" :size="20">
    <el-page-header @back="router.back()" size="small">
      <template #content>
        <span class="text-large font-600 mr-3">疾病信息编辑</span>
      </template>
    </el-page-header>
    <el-card class="w-fill" shadow="never">
      <el-space wrap class="w-fill" :size="20">
        <el-button type="info" size="small" @click="$.onReset(formRef)"
          >重置</el-button
        >
        <el-button type="primary" size="small" @click="$.onSubmit(formRef)"
          >提交</el-button
        >
      </el-space>
    </el-card>
    <el-card class="w-fill" shadow="never">
      <el-descriptions title="基本信息">
        <el-descriptions-item>
          <el-form
            ref="formRef"
            :model="_$.requestParam"
            :rules="_$.rules"
            label-width="auto"
            size="small"
            style="max-width: 600px"
          >
            <el-form-item label="名称" prop="name">
              <el-input v-model="_$.requestParam.name" />
            </el-form-item>
          </el-form>
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
  </el-space>
</template>

<style scoped>
.upload-control {
  width: 100%;
}
</style>
